/**time*/
/** gettimeofday*/
/**ctime_r */
/**localtime_r*/
/**gmtime_r*/
/**mktime*/
/**asctime*/
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
#include<sys/time.h>
#include<string.h>
int main()
{
	time_t t;
	t=time(NULL);
	if(-1==t){
		perror("time error");
		exit(-1);
	}
	printf("time_t:%ld\n",t);

	struct timeval tv;
	int ret;
	ret=gettimeofday(&tv,NULL);
	if(-1==ret){
		perror("gettimeofday error");
		exit(-1);
	}
	printf("time:%ld\n,mil_time:%ld\n",tv.tv_sec,tv.tv_usec);

	char tm_str[100]={0};
	ctime_r(&t,tm_str);
	puts(tm_str);

	struct tm local_t;
	localtime_r(&t,&local_t);
	printf("%d-%d-%d,%d:%d:%d,%d\n",local_t.tm_year+1900,local_t.tm_mon,local_t.tm_mday,local_t.tm_hour,local_t.tm_min,local_t.tm_sec,local_t.tm_wday);

	struct tm utc_tm;
	gmtime_r(&t,&utc_tm);
	printf("%d-%d-%d,%d:%d:%d,%d\n",utc_tm.tm_year+1900,utc_tm.tm_mon,utc_tm.tm_mday,utc_tm.tm_hour,utc_tm.tm_min,utc_tm.tm_sec,utc_tm.tm_wday);

	printf("time_t:%ld\n",mktime(&local_t));

	memset(tm_str,0x0,sizeof(tm_str));
	asctime_r(&local_t,tm_str);
	puts(tm_str);


	memset(tm_str,0x0,sizeof(tm_str));
	strftime(tm_str,sizeof(tm_str),"%Y-%m-%d %H:%M:%S<%p>%B %A %n",&local_t);
	puts(tm_str);
	return 0;

}
